//
//  AppDelegate.m
//  iOS-UIViewController
//
//  Created by 吴开杰 on 2020/2/19.
//  Copyright © 2020 吴开杰. All rights reserved.
//

#import "AppDelegate.h"
#import "XIBViewController.h"

@interface AppDelegate ()


@end
 
@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

     NSLog(@"%s",__func__);
     
    
//     // 创建指定rootViewController的方式一：（直接代码中创建）
//     // 纯代码中设置UIViewController
//     // 1.创建显示的Window，Window的大小和屏幕一样大
//     self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
//     // 2.创建一个UIViewController
//     UIViewController *vc  =  [[UIViewController alloc]init];
//     vc.view.backgroundColor = UIColor.redColor;
//     // 3.关联Window 和 UIViewController
//     self.window.rootViewController = vc;
//     // 4.将Window显示出来
//     [self.window makeKeyAndVisible];

    
    
    
    
    
    // 创建指定rootViewController的方式二：（stroryboard中创建）
    // 1.创建显示的Window，Window的大小和屏幕一样大
    self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
    
    // 2.找到stroryboard
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Me" bundle:nil];
    
    // 3.在stroryboard中设置标志，然后在代码中寻找
    // UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"abc"];
    // 或者寻找stroryboard中箭头指向的UIViewController
    // UIViewController *vc = [sb instantiateInitialViewController];
    // 或者使用xib
    // XIBViewController *vc = [[XIBViewController alloc]initWithNibName:@"XIBViewController" bundle:nil];
    XIBViewController *vc = [[XIBViewController alloc]init];
    // 4.关联Window 和 UIViewController
    self.window.rootViewController = vc;
    
    // 5.将Window显示出来
    [self.window makeKeyAndVisible];
    
    
    
    
    
    
    
    
     return YES;
 }

 // 程序进入非活动状态
 - (void)applicationWillResignActive:(UIApplication *)application {
     // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
     // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
     NSLog(@"%s",__func__);
 }

 // 程序进入后台
 - (void)applicationDidEnterBackground:(UIApplication *)application {
     // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
     // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
     NSLog(@"%s",__func__);
 }

 // 程序即将进入前台
 - (void)applicationWillEnterForeground:(UIApplication *)application {
     // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
     NSLog(@"%s",__func__);
 }

 // 程序进入活动状态
 - (void)applicationDidBecomeActive:(UIApplication *)application {
     // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
     NSLog(@"%s",__func__);
 }

 // 程序结束
 - (void)applicationWillTerminate:(UIApplication *)application {
     // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
     NSLog(@"%s",__func__);
 }


 @end
